package com.czh.subject.domain.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 自定义线程池
 * @author caozaihui
 * @since 2024/09/28
 */
@Configuration
public class ThreadPoolConfig {

    @Bean(name = "labelThreadPoolExecutor")
    public ThreadPoolExecutor getLabelThreadPool() {
        return new ThreadPoolExecutor(16, 120, 5,
                TimeUnit.SECONDS, new LinkedBlockingDeque<>(40), new CustomizableThreadFactory(),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }

}
